package trying.HasNullField;

import java.lang.reflect.Field;

/** 判断 Object内是否有空值
 * @author y
 */
public class FieldEmptyValidator <T> {
    public boolean hasNullOrEmptyFiled(T obj) throws IllegalAccessException {
        Class clazz = obj.getClass();
        Field[] fields = clazz.getDeclaredFields();
        for (Field field : fields) {
            field.setAccessible(true);
            Object value = field.get(obj);
            if (value == null || "".equals(value)) {
                return false;
            }
        }
        return true;
    }
}
